package com.andova.component.lbs;

import android.app.Application;
import android.content.Context;
import android.content.Intent;

import com.baidu.mapapi.SDKInitializer;

import androidx.annotation.NonNull;

/**
 * Created by Administrator on 2017-12-08.
 *
 * @author kzaxil
 * @since 0.0.2
 */
public class BaiDuComponent extends AndovaLbsComponent {
    private ILbsLocInfo mLbsLocInfo;
    private ILbsLocOption mLbsLocOption;

    public BaiDuComponent() {
    }

    public BaiDuComponent(ILbsLocInfo lbsLocInfo) {
        mLbsLocInfo = lbsLocInfo;
    }

    public BaiDuComponent(ILbsLocOption lbsLocOption) {
        mLbsLocOption = lbsLocOption;
    }

    public BaiDuComponent(ILbsLocInfo lbsLocInfo, ILbsLocOption lbsLocOption) {
        mLbsLocInfo = lbsLocInfo;
        mLbsLocOption = lbsLocOption;
    }

    @Override
    public ILbsLatLng lbsLatLng() {
        return null;
    }

    @Override
    public ILbsMapView lbsMapView() {
        return null;
    }

    @Override
    public ILbsLocMode lbsLocMode() {
        return null;
    }

    @Override
    public ILbsLocOption lbsLocOption() {
        return mLbsLocOption;
    }

    @Override
    public ILbsLocInfo lbsLocInfo() {
        return mLbsLocInfo == null ? BaiDuLocInfo.get() : mLbsLocInfo;
    }

    @Override
    public void lbsLocOption(ILbsLocOption lbsLocOption) {
        mLbsLocOption = lbsLocOption;
    }

    @Override
    public void lbsLocInfo(ILbsLocInfo lbsLocInfo) {
        mLbsLocInfo = lbsLocInfo;
    }

    @Override
    public void lbsRestartLocService(Context cxt, ILbsLocOption lbsLocOption) {
        lbsLocOption(lbsLocOption);
        cxt.stopService(new Intent(cxt, BaiDuLocService.class));
        cxt.startService(new Intent(cxt, BaiDuLocService.class));
    }

    @Override
    protected void onCreate(@NonNull Application cxt) {
        SDKInitializer.initialize(cxt);
        cxt.startService(new Intent(cxt, BaiDuLocService.class));
    }

    @Override
    protected void onLowMemory(@NonNull Application cxt) {
        cxt.stopService(new Intent(cxt, BaiDuLocService.class));
    }
}
